#e
#Title[wuVhEv]
#Text[]
#Image[]
#BackGround[]
#BGM[]
#PlayLevel[Extra]
#ScriptVersion[2]
#Player[FREE]

script_enemy_main
{
let wt=200;
let rot=0.2;
let usebomb=0;

	//GoɈxs镔
	@Initialize
	{
	//   eϐ

	//   XyJ[hf[^
	SetLife(800);
	SetScore(200000);
	SetDamageRate(30,  0);
	SetTimer(80);
	SetInvincibility(250);
	SetShotAutoDeleteClip(64,128,64,64);
	LoadGraphic("script\img\ExRumia.png");
	LoadUserShotData(GetCurrentScriptDirectory~"..\img\usershot.txt");
	CutIn(KOUMA,"wuVhEv",GetCurrentScriptDirectory~"..\img\cutin06.png",0,0,255,320);

	}
	//   ʒu܂ňړ
	SetMovePosition02(GetCenterX, GetCenterY, 60);

	BG_Standard;
	AtackTaskA;
	AtackTaskB;
	ControlTask;
	//G̃Ct0ɂȂ܂ŁA̕1t[1s
	@MainLoop
	{
		yield;


		if(OnBomb==false){
			SetCollisionA(GetX, GetY, 32);
			SetCollisionB(GetX, GetY, 24);
			usebomb=0;
		}
		else{
			usebomb++;
		}
		if(usebomb==1){
			BombBarrier;
		}
	}
	
	//`惋[vB1t[1s
	@DrawLoop
	{
		SetGraphicRect(64,1,127,64);
		if(GetSpeedX<0){
			SetGraphicRect(128,1,191,64);
		}
		if(GetSpeedX>0){
			SetGraphicRect(192,1,255,64);
		}
		SetColor(255,255,255);
		SetAlpha(255);
		if(OnBomb==true){SetAlpha(96);}
		SetTexture("script\img\ExRumia.png");//摜͔q
		DrawGraphic(GetX(),GetY());//G̍WEx[~A`;
	}
		
	//GłuԂɈxs镔
	@Finalize
	{
		DeleteGraphic("script\img\ExRumia.png");
		DeleteGraphic(GetCurrentScriptDirectory ~"..img\back1.png");
		DeleteGraphic(GetCurrentScriptDirectory ~"..img\back2.png");
	}
	//XyJ[h̔wi
	//Ă悢
	@BackGround
	{
		BG_Simple;
	}

	task AtackTaskA{	//[U[
		wait(120);
		let nway=4;
		let rotflag=0;
		loop{
			if(GetX<GetPlayerX){
				rotflag=1;
			}
			else{
				rotflag=-1;
			}
			let dir=rand(0,360);
			loop(nway){
				CreateLaserB(0,300,10,11,60);
				SetLaserDataB(0,0,0,-16,0,dir,rotflag*rot,dir,rotflag*rot);
				SetShotKillTime(0,wt);
				FireShot(0);
				CreateLaserB(0,300,10,12,60);
				SetLaserDataB(0,0,0,-16,0,dir+45,rotflag*rot,dir+45,rotflag*rot);
				SetShotKillTime(0,wt);
				FireShot(0);
				dir+=360/nway;
			}
			wait(wt);
		}
	}
	task AtackTaskB{	//e󂯂ŒeŔˌ
		wait(250);
		let nway=8;
		let hit=0;
		while(GetTimer>20){
			if(GetHitCount>0){hit++;}
			if(hit>0){
				let dir=0;
				loop(nway){
					CreateShot01(GetX*2-GetPlayerX,GetY*2-GetPlayerY,4,dir,RED01,0);
					dir+=360/nway;
				}
				hit=0;
			}
			wait(3);
		}
		loop{
			let dir=0;
			loop(nway){
				CreateShot01(GetX*2-GetPlayerX,GetY*2-GetPlayerY,4,dir,RED01,20);
				dir+=360/nway;
			}
			wait(6);
		}
	}

	task ControlTask{
		wait(250);
		while(GetEnemyLife>600&&GetTimer>20){yield;}
		rot=0.3;
		while(GetEnemyLife>400&&GetTimer>20){yield;}
		rot=0.4;
		while(GetEnemyLife>200&&GetTimer>20){yield;}
		rot=0.5;
		while(GetTimer>20){yield;}
		rot=0.6;
	}

	#include_function".\function.txt"
}

